
#import "FPObject.h"

@implementation FPObject

- Calc:sender
{

    char dummyString[20];
    float dummy1;
    float dummy2;
    float askingprice;
    float municipalevaluation;
    float offer;
    float percentasking;
    float percentmunicipal;


// Assign Variables

       	askingprice = [AskingPrice floatValue];
	municipalevaluation = [MunicipalEvaluation floatValue];
	offer = [Offer floatValue];


// This section finds the % in comparision with the
// Asking Price
// Formula is: Offer/Asking Price = X
//             Multiply X by 100 = Y
//             100 - Y = Value we want!    

	dummy1 = (offer/askingprice);
        dummy2 = (dummy1 * 100);
        percentasking = (dummy2 - 100);

        // Convert float to a string
        sprintf(dummyString, "%.2f", percentasking); 
        // Display result
	[PercentAsking setStringValue:dummyString];
	[PercentAsking display];


// This section finds the % in comparision with the
// Municipal Evaluation
// Formula is: Offer/Municipal Evaluation = X
//             Multiply X by 100 = Y
//             100 - Y = Value we want!    

	dummy1 = (offer/municipalevaluation);
        dummy2 = (dummy1 * 100);
        percentmunicipal = (dummy2 - 100);

        // Convert float to a string
        sprintf(dummyString, "%.2f", percentmunicipal); 
        // Display result
	[PercentMunicipal setStringValue:dummyString];
	[PercentMunicipal display];


	[Offer selectText:self];

    return self;
}

// AWAKEFROMNIB
// This is one of the last methods executed after the nib file is loaded.
// This is the BEST way I know how to initialize an object and jump into
// a method after the nib file was loaded, because you are all the methods
// and variables needed can be used. (Unlike init which is not compeletly
// ready when that message is sent
- awakeFromNib
{
 
	[FindPercentagePanel makeKeyAndOrderFront:NULL];
	[AskingPrice selectText:self];

    	return self;
}

@end
